home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-06-05 | 533 b | 29 lines | [MATF/MATL] |
- function Z = cs(S,X,T)
- % Z = cs(S,X,T)
- % Evaluates the spline created with csfit.m
- % S coefficient list, input.
- % X is the vector of abscissas, input.
- % T is the input value(s), input.
- % Z is the function value(s), output.
- n = length(X)-1;
- m = length(T);
- Z = zeros(1,m);
- for i=1:m,
- t = T(i);
- j = 0;
- k = n-1;
- while (j<=n-1);
- j=j+1;
- if (t<=X(j+1)),
- k=j-1;
- j=n+1;
- end
- end
- if (t<=X(1)),
- k = 0;
- end
- w = t-X(k+1);
- z=((S(k+1,3+1)*w + S(k+1,2+1))*w + S(k+1,1+1))*w + S(k+1,0+1);
- Z(i) = z;
- end
-